﻿package mortal.common.pools
{
    import flash.display.*;
    import flash.geom.*;
    import flash.utils.*;

    public class BitmapDataPool extends Object
    {
        private static var _matrix:Matrix = new Matrix();
        private static var _bitmapDataPool:Dictionary = new Dictionary();

        public function BitmapDataPool()
        {
            return;
        }// end function

        public static function drawBitmapData(param1:MovieClip, param2:int = 1) : BitmapData
        {
            var _loc_4:BitmapData = null;
            if (param1.totalFrames < param2)
            {
                return null;
            }
            param1.gotoAndStop(param2);
            var _loc_3:* = param1.getBounds(param1);
            if (_loc_3.height == 0 || _loc_3.width == 0)
            {
            }
            else
            {
                _loc_4 = new BitmapData(_loc_3.width, _loc_3.height, true, 0);
                _loc_4.draw(param1, null, null, null, null, false);
                return _loc_4;
            }
            return null;
        }// end function

        public static function getMaskBitmapData(param1:Number = 0, param2:Number = 0) : BitmapData
        {
            if (param1 == 0)
            {
                param1 = 1;
            }
            if (param2 == 0)
            {
                param2 = 1;
            }
            var _loc_3:* = param1 + "_" + param2;
            var _loc_4:* = _bitmapDataPool[_loc_3];
            if (_loc_4 == null)
            {
                var _loc_5:* = new BitmapData(param1, param2);
                _bitmapDataPool[_loc_3] = new BitmapData(param1, param2);
                _loc_4 = _loc_5;
            }
            return _loc_4;
        }// end function

    }
}
